package com.yuhong.reggie.mapper;

import com.yuhong.reggie.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {
    //根据用户id查询用户
    @Select("select * from user where Id=#{userId}")
    User findById(Long userId);

    //添加用户
    @Insert("insert into user(id,phone,status) values(null,#{phone},#{status})")
    //获取主键,后面要将注解写入session中
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    Integer save(User user);

    //根据手机号查询用户
    @Select("select * from user where phone=#{phone}")
    User findByPhone(String phone);
}
